﻿using NiceManage.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NiceManage.Common
{
    public class Categority
    {
        SqlSugarClient db = DbHelper.GetInstance();
        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns></returns>
        public List<m_categority> GetList()
        {
          return  db.Queryable<m_categority>().ToList();
        }
        /// <summary>
        /// 根据ID查询单条
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public m_categority GetCategorityByID(int ID)
        {
            return db.Queryable<m_categority>().Where(a => a.ID == ID).First();
        }
        /// <summary>
        /// 根据实体修改
        /// </summary>
        /// <param name="m_Categority"></param>
        /// <returns></returns>
        public int UpdateCategority(m_categority m_Categority)
        {
            
            return db.Updateable(m_Categority).ExecuteCommand();
        }

        public int DeleteCategority(int ID)
        {
            return db.Deleteable<m_categority>(a => a.ID == ID).ExecuteCommand();
        }

        public int AddCategority(m_categority m_Categority)
        {
            return db.Insertable<m_categority>(m_Categority).ExecuteCommand();
        }
    }
}
